<?php

/**
 * 开放接口
 */
class Api_WeOpen extends PhalApi_Api
{
    public function getRules()
    {
        return array(
//            'upload' => [
//            ],
//            'Register' => [
//                'pwd1' => ['name' => 'pwd1', 'type' => 'string', 'require' => true, 'min' => 1,'max' => 34,'desc' => '密码 md5 32位'],
//                'phone' => ['name' => 'phone', 'type' => 'string', 'require' => true, 'regex' => '/^[1][34578][0-9]{9}$/', 'desc' => '手机号码'],
//                'code' => ['name' => 'code', 'type' => 'string', 'require' => true, 'min' => 1,'max' => 12,'desc' => '密码']
//            ],
//            'Login' => [
//                'pwd1' => ['name' => 'pwd1', 'type' => 'string', 'require' => true, 'min' => 1,'max' => 34,'desc' => '密码md5'],
//                'phone' => ['name' => 'phone', 'type' => 'string', 'require' => true, 'regex' => '/^[1][34578][0-9]{9}$/', 'desc' => '手机号码']
//            ],
            'banner' => [
            ],
            'ConsultClassList'=>[
            ],
            'ConsultList'=>[
                'page' => ['name' => 'page', 'type' => 'int', 'require' => true,'desc' => '页码第一页传1'],
                'classId' => ['name' => 'classId', 'type' => 'int', 'require' => false,'desc' => '分类id'],
                'hot' => ['name' => 'hot', 'type' => 'int', 'require' => false,'desc' => '是否热门 要不不传要不传1'],
            ],
            'ConsultDetail'=>[
                'id' => ['name' => 'id', 'type' => 'int', 'require' => true,'desc' => '帖子id'],
                'type' => ['name' => 'type', 'type' => 'int', 'require' => false,'desc' => '1咨询 2视频 3快讯'],
            ],
            'CommentList'=>[
                'page' => ['name' => 'page', 'type' => 'int', 'require' => true,'desc' => '页码第一页传1'],
                'type' => ['name' => 'type', 'type' => 'int', 'require' => true,'desc' => '评论类型 1咨询 2视频 3快讯'],
                'fid' => ['name' => 'fid', 'type' => 'int', 'require' => true,'desc' => '帖子id'],
            ],
            'CommentListTwo' => [

            ],
            'getDataTest'=>[],
            'insertAppConsult' => [
                'consultName' => ['name' => 'consultName', 'type' => 'string', 'min' => 1,'max' => 50, 'require' => true, 'desc' => '咨询名称'],
                'consultImg' => ['name' => 'consultImg', 'type' => 'string',  'min' => 1,'max' => 150,'require' => false, 'desc' => '咨询图片链接'],
                'video' => ['name' => 'video', 'type' => 'string',  'min' => 1,'max' => 150,'require' => false, 'desc' => '视频链接'],
                'consultDetail' => ['name' => 'consultDetail', 'type' => 'string','require' => true, 'desc' => '咨询内容'],
                'top' => ['name' => 'top', 'type' => 'int','require' => true, 'desc' => '置顶顺序 默认1'],
                'className' => ['name' => 'className', 'type' => 'int', 'require' => true, 'desc' => '分类id'],
//                'authorName' => ['name' => 'authorName', 'type' => 'int', 'require' => true, 'desc' => '作者id'],
                'authorId' => ['name' => 'authorId', 'type' => 'int', 'require' => true, 'desc' => '作者id'],
                'recommendID' => ['name' => 'recommendID', 'type' => 'int', 'require' => false, 'desc' => '推荐模板id'],
                'hot'=>['name'=>'hot','type'=>'int', 'require' => false,'desc'=>'是否热门 0不是 1是']
            ],
        );
    }

//    /**
//     * 上传图片token
//     * @return int code 1操作成功
//     * @return string context 问题详细描述
//     * @return array data url
//     * @desc wjp 2017-12-25
//     */
//    public function upload(){
//        $token = DI()->qiniu-> getuptoken();
//        $res = DI()->ResCode->get("WE.Success");
//        $res['token'] = $token;
//        return $res;
//    }

//    /**
//     * 用户注册
//     * @return int code 1操作成功,2001当前用户已存在
//     * @return string context 问题详细描述
//     * @return array data 用户相关参数
//     * @desc wjp 2017-12-25
//     */
//    public function Register(){
//        $domain = new Domain_WeUser();
//        $allParams = $this -> allParams();
//        $res = $domain->Register($allParams);
//        return $res;
//    }

//    /**
//     * 用户登录
//     * @return int code 1操作成功,1001当前用户不存在,1002当前用户以被冻结,1003密码错误
//     * @return string context 问题详细描述
//     * @return array data 用户相关参数
//     * @desc wjp 2017-12-25
//     */
//    public function Login(){
//        $domain = new Domain_WeUser();
//
//        $user = $domain->Login($this->phone,$this->pwd1);
//        $res = DI()->ResCode->get("WE.Success");
//        $res['data'] = $user;
//        return $res;
//    }

//    /**
//     * 推荐获取
//     * @desc wjp 2017-1-4 如果没有data为空  3个不是固定的可能会少 比如后台删除咨询之内的情况
//     * @throws PhalApi_Exception_InternalServerError
//     */
//    public function getRecommend(){
//        $allParams = $this -> allParams();
//        $domain = new Domain_WeConsult();
//
//        $userInfo = $domain -> getRecommend($allParams['id']);
//        if($userInfo == null)
//            return DI()->ResCode->get("WE.Error");
//        $ret = DI()->ResCode->get("WE.Success");
//        $ret['data'] = $userInfo;
//        return $ret;
//    }
    /**
     * 轮换板
     * @return int code 1操作成功
     * @return string context 问题详细描述
     * @return array data 轮换板列表
     * @desc wjp 2017-12-26
     */
    public function bannerList(){
        $domain = new Domain_WeBanner();
        $list = $domain->bannerList();
        $res = DI()->ResCode->get("WE.Success");
        $res['data'] = $list;
        return $res;
    }

    /**
     * 帖子分类列表
     * @return int code 1操作成功
     * @return string context 问题详细描述
     * @return array data 分类列表
     * @desc wjp 2017-12-28
     */
    public function ConsultClassList(){
        $domain = new Domain_WeConsult();
        $list = $domain->ConsultClassList();
        $res = DI()->ResCode->get("WE.Success");
        $res['data'] = $list;
        return $res;
    }

    /**
     * 帖子列表
     * @return int code 1操作成功
     * @return string context 问题详细描述
     * @return array data 列表
     * @desc wjp 2017-12-28
     */
    public function ConsultList(){

        $allParams = $this -> allParams();
        $domain = new Domain_WeConsult();
        $list = $domain->ConsultList($allParams);
        $res = DI()->ResCode->get("WE.Success");
        $res['data'] = $list;
        return $res;
    }

    /**
     * 帖子详情
     * @return int code 1操作成功
     * @return string context 问题详细描述
     * @return array data 列表
     * @desc wjp 2017-12-28
     */
    public function ConsultDetail(){
        $allParams = $this -> allParams();
        $domain = new Domain_WeConsult();
        $list = $domain->ConsultDetail($allParams);
        $res = DI()->ResCode->get("WE.Success");
        $res['data'] = $list;
        return $res;
    }

    /**
     * 评论列表
     * @return int code 1操作成功
     * @return string context 问题详细描述
     * @return array data 列表
     * @desc wjp 2017-12-28
     */
    public function CommentList(){
        $allParams = $this -> allParams();
        $domain = new Domain_WeConsult();
        $list = $domain->CommentList($allParams);
        $res = DI()->ResCode->get("WE.Success");
        $res['data'] = $list;
        return $res;
    }

    /**
     * 新建咨询
     * @desc wjp 2017-1-4
     * @throws PhalApi_Exception_InternalServerError
     */
    public function insertAppConsult(){
        $allParams = $this -> allParams();
        $domain = new Domain_WeConsult();
        $userInfo = $domain -> insertAppConsult($allParams);
        $ret = DI()->ResCode->get("WE.Success");
        $ret['data'] = $userInfo;
        return $userInfo;
    }

    /**
     * 部分功能测试入库
     * @desc wjp 2017-1-5
     * @throws PhalApi_Exception_InternalServerError
     */
    public function getDataTest(){
        $domain = new Domain_WeData();
        $ret = $domain -> test2();
        return $ret;
    }

}